package HomeWork.chapter05.Test02;
import java.util.Scanner;
/**
 * Enjoy programming!!!
 * Time: 2021/11/30 -  19:44
 */
public class Test {
    public static void main(String[] args){
        AA a = new AA();

        System.out.println("请输入两个数：");

        Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        int y = in.nextInt();
        System.out.printf("%d和%d的最大公约数是：",x, y);
        System.out.println(a.f(x, y));

        BB s = new BB();
        a = s;
        System.out.printf("%d和%d的最小公倍数是：",x, y);
        System.out.println(a.f(x, y));
    }
}

class AA {
    public int f(int a1, int b1) {
        if(a1 < b1){
            int temp = a1;
            a1 = b1;
            b1 = temp;
        }
        while(a1 % b1 != 0){
            int temp = a1 % b1;
            a1 = b1;
            b1 = temp;
        }
        return b1;
    }
}
class BB extends AA{
    public int f(int a, int b){
        return a * b / super.f(a, b);
    }
}